package org.firebug.spring.boot.websocket.controller.web;

import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/apollo-socket")
public class WebSocketController {
	/**
	 * 后端向前端推送消息
	 */
	@RequestMapping(value = "/push/{sid}", method = {RequestMethod.GET})
	public Map<String, Integer> push(@PathVariable String sid, @RequestParam String message) throws IOException {
		WebSocketServer.sendMessage(sid, message);
		Map<String, Integer> response = new HashMap<>();
		response.put("code", 200);
		return response;
	} 
}
